package com.zxq.common.utils;

import com.zxq.common.utils.json.GsonTool;
import com.google.gson.reflect.TypeToken;

import java.util.List;
import java.util.Map;

public class GsonUtil {

    public static String toJson(Object obj) {
        return GsonTool.getInstance().toJson(obj);
    }

    public static <T> T toObject(String json, Class<T> clazz) {
        return GsonTool.getInstance().toObject(json,clazz);
    }

    public static <T> T toObject(String json, TypeToken<?> valueTypeRef) {
        return GsonTool.getInstance().toObject(json,valueTypeRef);
    }

    public static Map<String, Object> convertToMap(Object fromValue) {
        return GsonTool.getInstance().convertToMap(fromValue);
    }

    public static Map<String, Object> convertToMap(String json) {
        return GsonTool.getInstance().convertToMap(json);
    }

    public static <T> T toObject(byte[] result, Class<T> clazz) {
        return GsonTool.getInstance().toObject(result, clazz);
    }

    public static <T> List<T> toList(String json, Class<T> clazz) {
        return GsonTool.getInstance().toList(json, clazz);
    }

}

